<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	template="/layout/templateAdmin.xhtml">


	<ui:define name="head">

	</ui:define>	

	<ui:define name="conteudo" >
	
	<h:form id="formPrincipal">
	<p:panelGrid columns="2">
		<p:outputLabel value="Descrição"/>
		<p:inputText id="descricao" value="#{formaEntregaMb.obj.descricao}" label="Descrição" size="50" maxlength="50"
		  required="true" requiredMessage="Descrição é Obrigatória"/>
		  
		<p:outputLabel value="Taxa de Desconto"/>
		<p:inputText id="taxaDesconto" value="#{formaEntregaMb.obj.taxaDescontada}"
			required="true" requiredMessage="Taxa de Desconto Obrigatória" label="Taxa de Desconto" size="50" maxlength="50">
				<f:convertNumber pattern="#,###,##0.00" currencyCode="BRL" type="currency"/>
			</p:inputText>
		</p:panelGrid>
		
		<div class="boxComponentes">
		<div class="box_botoes" style="margin-top: 13px;">
		<p:commandButton value="Inserir" actionListener="#{formaEntregaMb.inserir()}"
		 update=":formDados :growl :formPrincipal" icon="ui-icon-disk"
		 rendered="#{empty formaEntregaMb.obj.id}"/>
		 
		 <p:commandButton value="Alterar" actionListener="#{formaEntregaMb.alterar}"
		 update=":formDados :growl :formPrincipal" icon="ui-icon-pencil"
		 rendered="#{not empty formaEntregaMb.obj.id}"/>
		 
		 <p:commandButton value="cancelar" actionListener="#{formaEntregaMb.limpar}"
		 update=":formDados :growl :formPrincipal" icon="ui-icon-cancel"
		 rendered="#{not empty formaEntregaMb.obj.id}"/>
		 
		 <p:commandButton value="Excluir" onclick="modalExclusao.show()"
		 icon="ui-icon-trash" rendered="#{not empty formaEntregaMb.obj.id}"/>
		</div>
	</div>
	
	</h:form>
	
		<h:form id="formDados">
		<p:dataTable id="lista" value="#{formaEntregaMb.lista}"
		var="obj" rowKey="#{obj.id}" selectionMode="single" 
		emptyMessage="Nenhum intem encontrado" 
		paginator="true" rows="5" paginatorPosition="bottom">
		
		<p:ajax event="rowSelect" listener="#{formaEntregaMb.selecionar}"
		update=":formPrincipal"/>
		
		<p:column sortBy="#{obj.id}">
			<f:facet name="hearder"> CODIGO</f:facet>
			<h:outputText value="#{obj.id}" />
		</p:column>
		<p:column sortBy="#{obj.descricao}">
	   		 <f:facet name="hearder"> DESCRIÇÃO</f:facet>
		     <h:outputText value="#{obj.descricao}"/>
		 </p:column>
		 <p:column sortBy="#{obj.taxaDescontada}">
		 <f:facet name="header">TAXA DESCONTADA</f:facet>
		 <h:outputText value="#{obj.taxaDescontada}">
		 	<f:convertNumber pattern="##0.00"
		 	currencyCode="BRL" type="currncy"/>
		 	</h:outputText>
		 	</p:column>
		 </p:dataTable>
	   </h:form>	
	   
	   <p:confirmDialog id="confirmExclusao" message="Excluir"
	   		appendToBody="true" header="Atenção" severity="alert"
	   		widgetVar="modalExclusao">
	   	<h:form id="formConfirmacao">
	   		<p:commandButton value="Sim" oncomplete="modalExclusao.hide()"
	   		actionListener="#{formaEntregaMb.excluir}"
	   		update=":formPrincipal :formDados :growl"/>
	   		<p:commandButton value="Não" onclick="modalExclusao.hide()" />
	   	</h:form>
	   </p:confirmDialog>
	</ui:define>
</ui:composition>